package fr.oz.mobile.common.ui 
{
	import caurina.transitions.Tweener;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import fr.digitas.flowearth.conf.Conf;
	import fr.digitas.flowearth.text.styles.styleManager;
	/**
	 * ...
	 * @author Fazermokeur
	 */
	public class SelectButton extends SetlectButton_FC
	{
		private var tf:TextField;
		
		public function SelectButton() 
		{
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			addEventListener(Event.REMOVED_FROM_STAGE, dispose);
			
			tf = new TextField();
			styleManager.apply(tf, ".profile_set_button", Conf.getDatas("wakeUpProfile").data.ui.validButton);
			addChild(tf);
			tf.x = ((width - tf.width) >> 1 ) >> 0;
			tf.y = -12;
			
			this.addEventListener(MouseEvent.MOUSE_DOWN, handleDown);
			
		}
		
		private function handleDown(e:MouseEvent):void 
		{
			Tweener.addTween(bg, { alpha:.6, time:.5 } );
			stage.addEventListener(MouseEvent.MOUSE_UP, handleUp);
		}
		
		private function handleUp(e:MouseEvent):void 
		{
			stage.removeEventListener(MouseEvent.MOUSE_UP, handleUp);
			Tweener.addTween(bg, { alpha:1, time:.5 } );
		}
		
		private function dispose(e:Event):void 
		{
			removeEventListener(Event.REMOVED_FROM_STAGE, dispose);
			removeChild(tf);
			tf = null;
		}
		
	}

}